<?php

namespace App\Model;

use Util\Common;

/**
 * 优惠券-模型
 */
class CouponImg extends Model
{

//    use TimeZoneTrait;

    public bool $timestamps = true;

    protected ?string $table = 'coupon_img';

    protected array $fillable = [
        'id','image','thumb','status','is_del','type'
    ];

    protected array $casts = [
        'created_at' => 'datetime:Y-m-d H:i:s',
        'updated_at' => 'datetime:Y-m-d H:i:s',
    ];

    /**返回优惠券图片
     * @param int $type
     * @return array
     */
    public function getOne(int $type = 2):array{
       return self::where('status',Common::DEL_SHOW)
            ->where('type',$type)
            ->where('is_del',Common::DEL_SHOW)
            ->get(['id','image'])->first()->toArray();
    }

}
